/*
Home of anything which is a global setting. Processor settings
such as clock rate and WDT are found here. So are the settings
for minimums and maximums
*/

#define dFoscExt        10000000UL       // External Crystal
#define dPLL            8               // PLL ratio
//#define dPWMPeriodInSec  0.000064          // PWM Period - 64 uSec, 15.625khz PWM
#define dPWMFreq		16000 			//switching frequency in hertz. 
#define dPWMPeriodInSec  1.0f / dPWMFreq  		//The time period in seconds
#define dPWMMax			2048 //(2^Max Resolution. Calculate this if you change PWM speed or clock speed

#define dFosc       (dFoscExt*dPLL)     // Clock frequency (Hz). dFosc = 64,000,000 in this case.
#define dFcy        (dFoscExt*dPLL/4)           // Instruction cycle frequency (Hz). dFcy = 16,000,000 in this case.
#define dTcy        (4.0/(dPLL*dFoscExt))          // Instruction cycle period (sec). 1/16,000,000 second

#define dPWMPeriodInTcy  (int)(dPWMPeriodInSec/dTcy)   // Basic loop period in units of Tcy.
//#define MAX_CURRENT_REF 2047 // (dPWMPeriodInTcy - 1) // 1023

#define NUM_TICKS 1024

// Output pins.
#define PRECHARGE_RELAY  _RC13  // output
#define CONTACTOR_RELAY  _RC14  // output
#define STATUS_LED 		 _RF6  // output
#define OVER_CURRENT_TRIP_RESET _RD3  // output
#define OVER_CURRENT_TRIP_STATE _RD0  // input

#define SET_HIGH(PIN)	PIN = 1;
#define SET_LOW(PIN)	PIN = 0;
#define SET_OUTPUT(PIN)	PIN = 0;
#define SET_INPUT(PIN)	PIN = 1;

